import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

/**
 * @Grup:PACKAGE_NAME
 * @Auther:cola
 * @Data:2021/3/29-2021-03-20:59
 * @version:1.0
 * Queue接口:队列,是一种先进先出的线性数据结构(排队)
 * LinkedList类实现了Queue接口
 * 请求队列,消息队列
 * Deque接口:双端队列
 * Stack类:
 */
public class QueueDequeDemo {
    private static void queue(){
        Queue<String> queue=new LinkedList<>();
        queue.add("消化");
        queue.add("小小");
        queue.add("笑实际");
        queue.add("为来");
        queue.add("什么");
        System.out.println(queue.size());
        System.out.println(queue.peek());
        System.out.println(queue.size());
        System.out.println(queue.poll());
        System.out.println(queue.size());
    }

    //双端队列
    private static void deque(){
        Deque<String> deque=new LinkedList<>();
        deque.add("消化");
        deque.add("小小");
        deque.add("笑实际");
        deque.add("为来");
        deque.add("什么");
        System.out.println(deque.getFirst());
        System.out.println(deque.getLast());
    }
    //双端队列
    private static void stack(){
        Stack<String> stack=new Stack<>();
        //压栈
        stack.push("弟弟");
        stack.add("ada");
        stack.push("得到");
        System.out.println(stack);
        System.out.println(stack.peek());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
    }

    public static void main(String[] args) {
        //queue();
        //deque();
        stack();
    }
}
